package org.xx.armory.swing.builders;

import org.xx.armory.objectparser.ParsedObjectBuilder;

public class TabModelBuilder
        extends ParsedObjectBuilder<TabModel>
        implements ContainerModelBuilder {
    private String title;
    private String description;
    private ComponentModel child;

    public TabModelBuilder() {
    }

    public TabModelBuilder setTitle(
            String title
    ) {
        this.title = title;
        return this;
    }

    public TabModelBuilder setDescription(
            String description
    ) {
        this.description = description;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public TabModelBuilder addChild(
            ComponentModel child
    ) {
        if (this.child != null) {
            throw new IllegalStateException("child of tab is not null: " + this.child);
        }

        this.child = child;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public TabModel build() {
        return new TabModel(getLineInfo(), this.title, this.description, this.child);
    }
}
